package com.zcl.javaClassAndObject.classLocalDate;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.time.LocalDate;
import java.time.Month;

/**
 * @Description:
 * @author: zcl
 * @date: 2021/12/3  10:58
 */
public class LocalDateCls {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        //构造一个新对象，表示构造这个对象时的日期。
        LocalDate now = LocalDate.now();
        System.out.println(now);
        //执行结果为:
        /**
          *2021-12-03
          */

        //根据反射,获取now的类型
        System.out.println(now.getClass().getName());
        //执行结果为:
        /**
          *java.time.LocalDate
          */

        //可以提供年、 月和日来构造对应一个特定日期的对象：
        LocalDate newYearEve = LocalDate.of(1999, 12, 31);
        int year = newYearEve.getYear();
        System.out.println(year);
        Month month = newYearEve.getMonth();
        int monthValue = newYearEve.getMonthValue();
        System.out.println(month);
        System.out.println(monthValue);
        int dayOfMonth = newYearEve.getDayOfMonth();
        System.out.println(dayOfMonth);
        //执行结果为:
        /**
         *1999
         * DECEMBER
         * 12
         * 31
         */

        //plusDate方法会得到一个新的 LocalDate, 如果把应用这个方法的对象称为当前对象，这个新日期对象则是距当前对象指定天数的一个新日期
        LocalDate aThousandDaysLater = newYearEve.plusDays(1000);
        year = aThousandDaysLater.getYear();// 2002
        month = aThousandDaysLater.getMonth(); // 09
        dayOfMonth = aThousandDaysLater.getDayOfMonth(); // 26


        String name = aThousandDaysLater.getClass().getName();

        Class cl = Class.forName(name);
        System.out.println(cl);

        if (newYearEve.getClass() == aThousandDaysLater.getClass()){
            System.out.println("类型相同");
        }

//        LocalDate date = newYearEve.getClass().newInstance();
        Class aClass = Class.forName("java.lang.String");
        Method[] methods = aClass.getMethods();
        System.out.println(methods);
        System.out.println("********************");
        Field[] fields = aClass.getFields();
        System.out.println(fields);
        System.out.println("********************");
        Constructor<?>[] constructors = aClass.getConstructors();
        System.out.println(constructors);






    }
}
